package com.itheima.exception;

import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @Description:
 * @Version: V1.0
 */
@Component
@ControllerAdvice
public class ProjectException {

    @ExceptionHandler(BusinessException.class)
    public String doBusinessException(Exception ex, Model m){
        m.addAttribute("msg",ex.getMessage());
        return "error.jsp";
    }

    @ExceptionHandler(SystemException.class)
    public String doSystemException(Exception ex, Model m){
        m.addAttribute("msg","服务器出现问题，请联系管理员！");
        return "error.jsp";
    }

    @ExceptionHandler(Exception.class)
    public String doException(Exception ex, Model m){
        m.addAttribute("msg",ex.getMessage());
        return "error.jsp";
    }

}
